package com.gxar.marketdelivery.interfaces.web.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

@Data
@ApiModel("基础页面信息")
public class CommonPageResult<T> implements IPageResult<T> {

    @ApiModelProperty("当前页")
    private Integer pageNow;

    @ApiModelProperty("每页大小")
    private Integer pageSize;

    @ApiModelProperty("返回结果数量")
    private Long count;

    @ApiModelProperty("返回结果列表")
    private List<T> list;


    @Override
    public Integer getPageNow() {
        return pageNow;
    }

    public void setPageNow(Integer pageNow) {
        this.pageNow = pageNow;
    }

    @Override
    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    @Override
    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public static <T> CommonPageResult<T> build(IPageResponse pageResponse, List<T> list) {
        CommonPageResult<T> pageResult = new CommonPageResult<>();
        pageResult.setPageNow(pageResponse.getPageNow());
        pageResult.setPageSize(pageResponse.getPageSize());
        pageResult.setCount(pageResponse.getCount());
        pageResult.setList(list);
        return pageResult;
    }
}
